﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;



using Meqs.Entity;
using Meqs.Entity.Views;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    public class ClassResultExamListLogic : CommonLogic<ClassResultExamList, int>, IClassResultExamListLogic
    {
        #region Implementation of ICommonLogic<ClassResultExamList, int>

        /// <sammury>
        /// 创建对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(ClassResultExamList entity)
        {
            return CreateObject(entity);
        }

        /// <sammury>
        /// 更新对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(ClassResultExamList entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public ClassResultExamList FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<ClassResultExamList> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<ClassResultExamList> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion

        /// <summary>
        /// 查找学期内的指定班级(年级)考试得分分数
        /// </summary>
        public IList<TestScoreInTermView> FindTestScoreInTerm(String schoolMark, int schoolYear, int term, int? grade, int? classId, IList<int> causeIDList)
        {
            Hashtable ht = new Hashtable();   
            ht.Add("SchoolMark", schoolMark);
            ht.Add("SchoolYear", schoolYear);
            ht.Add("Term", term);
            if(grade != null)
                ht.Add("Grade", grade);
            if (classId != null)
                ht.Add("ClassID", classId);
            if(causeIDList != null && causeIDList.Count > 0)
                ht.Add("CauseIDList", causeIDList);
            return FindCustomer<TestScoreInTermView>("ClassResultExamList.FindTestScoreInTerm", ht);
        }

        public IList<TestScoreInTermView> FindMoralInTerm(String schoolMark, int schoolYear, int term, int? grade)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("SchoolYear", schoolYear);
            ht.Add("Term", term);
            ht.Add("Grade", grade);
            return FindCustomer<TestScoreInTermView>("ClassResultExamList.FindMoralInTerm", ht);
        }

        /// <summary>
        /// 查找个人成绩历史
        /// </summary>
        /// <param name="stuID"></param>
        /// <returns></returns>
        public IList<StudentTestScoreView> FindTestScoreHistoryByStuID(String schoolMark, int stuID)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("StuID", stuID);
            return FindCustomer<StudentTestScoreView>("ClassResultExamList.FindTestScoreHistoryByStuID", ht);
        }
    }
}